go to previous page   go to home page   go to next page

Answer:

Some outside agent might change the Color object that color refers to, and the Circle object would now have a different color. This might not be wanted.


Color Test Applet

Here is an applet that tests the new features. It draws ten circles in red and ten circles in blue. The red circles are moved slightly to the left, and the blue circles are moved slightly to the right.

// assume that the drawing area is 200 by 200
public class TestCircleRedBlue extends JApplet
{
  Circle circ = new Circle();
  
  public void paint ( Graphics gr )
  { 
    setBackground(Color.black);

    int count = 1;
    while ( count <= 10 )
    {
      circ.setRadius(  (100/10)*count );

      circ.setColor( Color.blue );
      circ.setPosition( 100+count/2, 100 );
      circ.draw( gr );

      circ.setColor( Color.red );
      circ.setPosition( 100-count/2, 100 );
      circ.draw( gr );

      count = count + 1;
    }
  }
}

Here is what the applet draws.

If you don't see an applet here, your browser does not support applets.

QUESTION 14:

What would you do if you had a pair of red/blue 3D vision glasses?